package taskoauthproject;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.api.client.auth.oauth2.AuthorizationCodeFlow;
import com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeServlet;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.File;
import com.google.api.services.tasks.Tasks;
import com.google.api.services.tasks.model.TaskList;
import com.google.api.services.tasks.model.TaskLists;

@SuppressWarnings("serial")
public class TaskServlet extends AbstractAppEngineAuthorizationCodeServlet{

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
		
		Tasks service = Utils.loadTaskService();
		
		System.out.println(service.tasklists().list().execute().size());
		
		
		
		resp.setContentType("text/html");
		
		
		
		TaskLists taskLists = service.tasklists().list().execute();
		
		resp.getWriter().println(taskLists.getItems().size());
		
	}

	@Override
	protected AuthorizationCodeFlow initializeFlow() throws ServletException,
			IOException {
		
		return Utils.newFlow();
	}

	@Override
	protected String getRedirectUri(HttpServletRequest req)
			throws ServletException, IOException {
		
		return Utils.getRedirectUri(req);
	}
	
}
